package com.jiepuxun.demo.influxDB;

import com.jiepuxun.demo.common.Ret;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.UUID;

@RequestMapping("/influx")
@RestController
public class InfluxDBController {

    @Autowired
    private MonitorDataMapper mapper;

    @PostMapping("/set")
    public Ret setData(){
        MonitorData data = new MonitorData();
        data.setUserId("clare");
        data.setHeartRate(75.0);
        data.setRespiratoryRate(30.0);
        data.setOther(0);
        mapper.insertOne(data);
        return Ret.ok();
    }

    @GetMapping("/get")
    public Ret getData(){
        List<MonitorData> list = mapper.selectAll();
        return Ret.ok().setData("list",list);
    }
}
